<script>
	var doexesql='__URL__/doexesql';
	var dourlencode='__URL__/dourlencode';
</script>
<!--table部分-->
<div class='col-md-12' style='padding-top:50px'>
	<div class="input-group">
	  <input type="text" class="form-control" placeholder="input sql sentence" aria-describedby="basic-addon2" id='sqltxt' value="select * from tb_aa LEFT JOIN tb_bb ON f_aa_bbid=bbid LEFT JOIN tb_cc ON f_aa_ccid=ccid where 1=1 ORDER BY aaid ASC LIMIT 0,10">
	  <span class="input-group-addon" id="exesql" style='cursor:pointer'>get json</span><span class="input-group-addon" id="exesql_arr" style='cursor:pointer'>get array</span><span class="input-group-addon" id="exesql_arr_table" style='cursor:pointer'>get array table</span>
	</div>
	<div id='result' style="padding-top:50px;"></div>
</div>

<script type="text/javascript">
$(function(){
	$('#exesql').click(function(){
		var obj=new Object();
		obj['sqltxt']=$.trim($('#sqltxt').val());
		$.ajax({
            'type': 'GET',
            'url':doexesql,
            'async':false,  
            'contentType': 'application/json',
            'data': obj,
            'dataType': 'json',
            'success': function(data) {
            	
            	var result=data['result']
            	$('#result').html("<?php p('"+result+"') ?>");

                console.log("success");
            },
            'error':function() {
                console.log("error");
            }
        });
	})
	$('#exesql_arr').click(function(){
		var obj=new Object();
		obj['sqltxt']=$.trim($('#sqltxt').val());
		$.ajax({
            'type': 'GET',
            'url':dourlencode,
            'async':false,  
            'contentType': 'application/json',
            'data': obj,
            'dataType': 'json',
            'success': function(data) {
            	
            	var url='__URL__/showsqlresult/sqltxt/'+data['url_tail'];
            	window.location.href=url;
            	
                console.log("success");
            },
            'error':function() {
                console.log("error");
            }
        });
	})
    $('#exesql_arr_table').click(function(){
        var obj=new Object();
        obj['sqltxt']=$.trim($('#sqltxt').val());
        $.ajax({
            'type': 'GET',
            'url':dourlencode,
            'async':false,  
            'contentType': 'application/json',
            'data': obj,
            'dataType': 'json',
            'success': function(data) {
                
                var url='__URL__/showsqlresult_table/sqltxt/'+data['url_tail'];
                window.location.href=url;
                
                console.log("success");
            },
            'error':function() {
                console.log("error");
            }
        });
    })
})
</script>


